﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using umbraco.cms.presentation.Trees;

namespace ExtendedWorkFlow
{

    public class loadWorkFlow : BaseTree
    {

        #region Constructor

        public loadWorkFlow(string application)
            : base(application)
        { }

        protected override void CreateRootNode(ref XmlTreeNode rootNode)
        {
            rootNode.Icon = FolderIcon;
            rootNode.OpenIcon = FolderIconOpen;
            rootNode.NodeType = "init" + TreeAlias;
            rootNode.NodeID = "init";
        }

        #endregion

        #region Render

        public override void Render(ref XmlTree Tree)
        {
            if (this.NodeKey == string.Empty)
            {
                XmlTreeNode objSettings = XmlTreeNode.Create(this);
                objSettings.NodeID = "1";
                objSettings.Text = "WorkBox";
                objSettings.Icon = "folder.gif";
                //objSettings.Source = GetTreeServiceUrl(objSettings.NodeID);
                objSettings.Action = "javascript:openWorkBox()";
                Tree.Add(objSettings);
            }            
        }

        public override void RenderJS(ref StringBuilder Javascript)
        {
            Javascript.Append(@"
                function openWorkBox() {
                    parent.right.document.location.href = 'WorkFlow/workbox.aspx';
                }
			");           
        }

        #endregion

    }

}
